using Microsoft.AspNetCore.Mvc;
using zhwy.saas.api.Entity.Sys;
using zhwy.saas.api.Models;
using zhwy.saas.api.Services.Sinterface.Sys;

namespace zhwy.saas.api.Controllers.V1.Sys
{
    /// <summary>
    /// 用户角色关联管理
    /// </summary>
    [ApiVersion("1.0")]
    public class SysUserRoleController : BaseController<Users_rolesEntity>
    {
        private readonly ISysUserRoleService _sysUserRoleService;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="sysUserRoleService">用户角色关联服务</param>
        public SysUserRoleController(ISysUserRoleService sysUserRoleService)
            : base(sysUserRoleService)
        {
            _sysUserRoleService = sysUserRoleService;
        }

        ///// <summary>
        ///// 分配用户角色
        ///// </summary>
        ///// <param name="userId">用户ID</param>
        ///// <param name="roleIds">角色ID列表</param>
        ///// <returns>分配结果</returns>
        ///// <response code="200">角色分配成功</response>
        ///// <response code="400">角色分配失败</response>
        //[HttpPost("user/{userId}/roles")]
        //[ProducesResponseType(typeof(ApiResponse<bool>), 200)]
        //[ProducesResponseType(typeof(ApiResponse<bool>), 400)]
        //public async Task<ActionResult<ApiResponse<bool>>> AssignRoles(long userId, [FromBody] List<int> roleIds)
        //{
        //    var result = await _sysUserRoleService.AssignRolesAsync(userId, roleIds);
        //    return result
        //        ? ApiResponse<bool>.Ok(true, "角色分配成功")
        //        : ApiResponse<bool>.Error("角色分配失败");
        //}

        ///// <summary>
        ///// 移除用户角色
        ///// </summary>
        ///// <param name="userId">用户ID</param>
        ///// <returns>移除结果</returns>
        ///// <response code="200">角色移除成功</response>
        ///// <response code="400">角色移除失败</response>
        //[HttpDelete("user/{userId}/roles")]
        //[ProducesResponseType(typeof(ApiResponse<bool>), 200)]
        //[ProducesResponseType(typeof(ApiResponse<bool>), 400)]
        //public async Task<ActionResult<ApiResponse<bool>>> RemoveUserRoles(long userId)
        //{
        //    var result = await _sysUserRoleService.RemoveUserRolesAsync(userId);
        //    return result
        //        ? ApiResponse<bool>.Ok(true, "角色移除成功")
        //        : ApiResponse<bool>.Error("角色移除失败");
        //}

        ///// <summary>
        ///// 获取用户角色ID列表
        ///// </summary>
        ///// <param name="userId">用户ID</param>
        ///// <returns>角色ID列表</returns>
        ///// <response code="200">成功获取角色ID列表</response>
        //[HttpGet("user/{userId}/roles")]
        //[ProducesResponseType(typeof(ApiResponse<List<int>>), 200)]
        //public async Task<ActionResult<ApiResponse<List<int>>>> GetUserRoleIds(long userId)
        //{
        //    var roleIds = await _sysUserRoleService.GetRoleIdsByUserIdAsync(userId);
        //    return ApiResponse<List<int>>.Ok(roleIds);
        //}

        ///// <summary>
        ///// 检查用户角色
        ///// </summary>
        ///// <param name="userId">用户ID</param>
        ///// <param name="roleId">角色ID</param>
        ///// <returns>是否拥有角色</returns>
        ///// <response code="200">成功检查角色</response>
        //[HttpGet("user/{userId}/role/{roleId}")]
        //[ProducesResponseType(typeof(ApiResponse<bool>), 200)]
        //public async Task<ActionResult<ApiResponse<bool>>> CheckRole(long userId, int roleId)
        //{
        //    var hasRole = await _sysUserRoleService.HasRoleAsync(userId, roleId);
        //    return ApiResponse<bool>.Ok(hasRole);
        //}
    }
}